//
//  MyAdInfoCell.swift
//  Automobile
//
//  Created by erkebulan elzhan on 8/22/20.
//  Copyright © 2020 erkebulan elzhan. All rights reserved.
//

import UIKit

final class MyAdInfoCell: UITableViewCell, ConfigurableCell {
 
    private lazy var itemsStack: UIStackView = {
        let stack = UIStackView()
        stack.spacing = 0
        stack.axis = .vertical
        stack.alignment = .leading
        stack.distribution = .fillProportionally
        return stack
    }()
    
    private lazy var leftDaysItem: ListTile = {
        let item = ListTile()
        item.snp.makeConstraints { (make) in
            make.height.equalTo(24)
        }
        return item
    }()
    private lazy var visCountItem: ListTile = {
       let item = ListTile()
       item.snp.makeConstraints { (make) in
           make.height.equalTo(24)
       }
       return item
   }()
    
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.addViews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    func configure(data: MyAdViewModel.MyAdInfoData?, index: Int) {
        visCountItem.updateUI(image: UIImage(named: "time"), text: data!.countTxt)
        leftDaysItem.updateUI(image: UIImage(named: "eye"), text: data!.leftDays)
    }
    
    func returnData() -> MyAdViewModel.MyAdInfoData? {
        return nil
    }
    
    private func addViews () {
        addSubview(itemsStack)
        itemsStack.snp.makeConstraints { (make) in
            make.leading.trailing.equalToSuperview().inset(16)
            make.top.bottom.equalToSuperview().inset(14)
        }
        
        //itemsStack.addArrangedSubview(leftDaysItem)
        itemsStack.addArrangedSubview(visCountItem)
    }
    
}
